# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: 06_GET请求爬取数据实战.py
# Time: 17:56

from urllib import request
from urllib import error
import re

url = "http://bj.58.com/job/?key=python&final=1&jump=1"
req = request.Request(url)

try:
    response = request.urlopen(req)
    html = response.read().decode("utf-8")
    pat = '<span class="address" >(.*?)</span>  \| <span class="name">(.*?)</span>'
    dlist = re.findall(pat,html)
    for v in dlist:
        print(v[0] + ":" +v[1])
except error.URLError as e:
    print(e.reason)
